package com.pictureBook.merchant.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.pictureBook.merchant.entity.StoreVipSetmeal;
import com.pictureBook.merchant.mapper.StoreVipSetmealMapper;
import com.pictureBook.merchant.service.IStoreVipSetmealService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author Ding
 * @since 2022-01-26
 */
@Service
public class StoreVipSetmealServiceImpl extends ServiceImpl<StoreVipSetmealMapper, StoreVipSetmeal> implements IStoreVipSetmealService {

    @Resource
    private StoreVipSetmealMapper mapper;

    @Override
    public PageInfo<StoreVipSetmeal> getList(Integer soId, String key,Integer index,Integer num) {
        PageHelper.startPage(index,num);
        QueryWrapper<StoreVipSetmeal> wrapper = new QueryWrapper();
        wrapper.eq("so_id",soId);
        if (key!=null && !key.equals("")){
            wrapper.like("so_v_setmeau_name",key);
        }
        return new PageInfo<>(mapper.selectList(wrapper));
    }

    @Override
    public int addLendPlan(StoreVipSetmeal bean) {
        return mapper.insert(bean);
    }

    @Override
    public int editLendPlan(StoreVipSetmeal bean) {
        QueryWrapper<StoreVipSetmeal> wrapper = new QueryWrapper();
        wrapper.eq("so_v_setmeau_id",bean.getSoVSetmeauId());
        return mapper.update(bean,wrapper);
    }

    @Override
    public int deleteLendPlan(List<Integer> ids) {
        QueryWrapper<StoreVipSetmeal> wrapper = new QueryWrapper<>();
        wrapper.in("so_v_setmeau_id",ids);
        return mapper.delete(wrapper);
    }
}
